local HeroModel = class("HeroModel")
local UIUtil = require("utils.UIUtil")
local GameUtils = require("utils.GameUtils")
local Vector3 = require("utils.Vector3")

function HeroModel:ctor()
end

function HeroModel:awake()
    printDebug("HeroModel:awake")
end

function HeroModel:setCallback(callback)
    self._callback = callback
end

function HeroModel:start()
    self._heroSpine:setCallback(handler(self, self._onClickHero))
    self._btnAdd.onClick:AddListener(handler(self, self._onAddClick))
end

function HeroModel:updateUI(unit)
    self._btnAdd.gameObject:SetActive(false)
    self._heroSpine.gameObject:SetActive(true)
    self._heroSpine:updateUI(unit:getBase_id())
    self._heroName.text = unit:getConfig().name
end

function HeroModel:updateEmpty()
    self._heroSpine.gameObject:SetActive(false)
    self._btnAdd.gameObject:SetActive(true)
    self._heroName.text = ""
end

function HeroModel:_onAddClick()
    if self._callback then
        self._callback(1)
    end
end

function HeroModel:_onClickHero()
    if self._callback then
        self._callback(2)
    end
end

function HeroModel:onDestroy()
end

return HeroModel
